// 导入数据库操作模块
const db = require('../../db/index')
const { calculateSolarTerm, getCurrentTime } = require('../../utils/user')

// 获取主页推荐信息
exports.getHomeRecommend = (req, res) => {
    // 获取当前节气
    let date = getCurrentTime('date').split('/')
    console.log(date)
    let solarTerm = calculateSolarTerm(date[0], date[1], date[2])
    console.log(solarTerm)
    const selectSql = `select * from poetry2 where p_state=1`
    db.query(selectSql, (err, selectRes) => {
        if(err) return res.operationSuccess('failure', 'ERR040', '获取朝代信息失败！', [])
        return res.operationSuccess('success', '', '获取朝代信息成功！', selectRes)
    })
}

